<template>
  <div class="success_box">
    <div class="nr_box">
      <div class="bj">
        <img src="/static/images/mb.png" alt="">
        <p :style="{height:navBarHeight+'px'}"></p>

      </div>
      <div class="box">
        <div class="title_box">
          <p class="icon"><van-icon name="success" /></p>
          <p class="title">预定成功</p>
        </div>
        <p class="line"></p>
        <div class="msg_box" :style="{height:height+'rpx'}">
          <p class="jb" v-if="height"></p>
          <p class="price"><span>￥</span>{{msg.realPrice}}</p>
          <div class="box">
            <p class="title">订单编号</p>
            <p class="text">{{msg.orderCode}}</p>
          </div>
          <div class="box">
            <p class="title">下单时间</p>
            <p class="text">{{msg.createTime}}</p>
          </div>
          <div class="box">
            <p class="title">支付方式</p>
            <p class="text">{{msg.payType?'钱包支付':'微信支付'}}</p>
          </div>
          <div class="anniu_box">
            <p @click="tohome">返回首页</p>
            <p @click="toOrder">查看订单</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>

import { 
  getPaySuccessOrder
} from "@/api/index";
export default {
  components: {
  },
  data() {
    return{
      statusBarHeight: "", // 状态栏高度
      titleBarHeight: "", // 标题栏高度
      navBarHeight: "", // 导航栏总高度
      height:0,
      msg:{}
    }
  },
  onShow() {
    setTimeout(() => {
      this.height = 550
    }, 500);
  },
  methods: {
    toOrder(){
      wx.switchTab({
        url: "/pages/order/main",
      });
    },
    tohome(){
      wx.switchTab({
        url: "/pages/home/main",
      });
    },

    getOrderMsg(orderId){
      getPaySuccessOrder({orderId}).then(res=>{
        if(res.statusCode == '00000'){
          this.msg = res.data
        }
      })
    }
  },
  onHide() {},
  onLoad(options) {
    console.log(options)
    this.getOrderMsg(options.orderId)
  },
  beforeMount() {
    const self = this;
    wx.getSystemInfo({
      success(system) {
        console.log(`system:`, system);
        self.statusBarHeight = system.statusBarHeight;
        let platformReg = /ios/i;
        if (platformReg.test(system.platform)) {
          self.titleBarHeight = 44;
        } else {
          self.titleBarHeight = 48;
        }
        self.navBarHeight = self.statusBarHeight + self.titleBarHeight;
      },
    });
  },
  onUnload() {
    this.height = 0
  },
  created() {}
};
</script>

<style lang="scss"  scoped>
.success_box {
  width: 100%;
  min-height: 100vh;
  background: #F8F9FA;
  .nr_box{
    width: 100%;
    padding-bottom:50rpx;
    .bj{
      img{
        display: block;
        position: fixed;
        top:0;
        left: 0;
        width: 100%;
        height: 534rpx;
        z-index: 10;
      }
    }
    .box{
      position: relative;
      z-index: 10;
      .title_box{
        display: flex;
        justify-content: center;
        align-items: center ;
        .icon{
          width: 52rpx;
          height: 52rpx;
          background: #383838;
          border-radius: 50%;
          color:#fff;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size:40rpx;
        }
        .title{
          color:#383838;
          font-size:40rpx;
          font-weight: 500;
          margin-left:16rpx;
        }
      }
      .line{
        width: 90%;
        height: 24rpx;
        background: linear-gradient(to right, #92A656, #90A555);
        border-radius: 30rpx;
        margin:40rpx auto 0 auto;
      }
      .msg_box{
        background: #fff;
        width: 86%;
        height: 0;
        margin:0 auto;
        margin-top:-10rpx;
        box-shadow: 0rpx 10rpx 20rpx 4rpx rgba(180, 177, 172, 0.1);
        border-bottom-right-radius: 30rpx;
        transition: all 1.5s;
        overflow: hidden;
        .jb{
          width: 100%;
          height: 50rpx;
          background: linear-gradient(to bottom, #C6CE9E 0%, #ffffff 50%);
        }
        .price{
          font-size:60rpx;
          font-weight: bold;
          color:#383838;
          text-align: center;
          margin-bottom:46rpx;
          span{
            font-size:40rpx;
          }
        }
        .box{
          margin:0 30rpx;
          display: flex;
          align-items: center;
          justify-content: space-between;
          font-size:28rpx;
          height: 60rpx;
          .title{
            color:#666666;
          }
          .text{
            color:#383838;
          }
        }
      }
      .anniu_box{
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top:80rpx;
        p{
          width: 220rpx;
          height: 70rpx;
          line-height: 70rpx;
          border:1px solid #8FB162;
          font-size:26rpx;
          color:#383838;
          text-align: center;
          border-radius: 50rpx;
          &:last-child{
            margin-left:48rpx;
          }
        }
      }
    }
  }
}
</style>
